import request from '@/config/axios'

// 活动 VO
export interface ActivityVO {
  id: number // 编号
  activityTitle: string // 活动标题
  iconUrl: string // 图标
  typeId: number // 活动分类
  categoryId: number //活动种类
  userIds: string // 参与人员
  copyUserIds: string // 抄送人员
  fileUrls: string // 附件
  activityContent: string // 活动内容
  startTime: Date // 活动开始时间
  endTime: Date // 活动结束时间
  sort: number // 排序
  status: number // 状态
  copyUserNames: string[] //抄送人员
  userName: string //创建者
  userNames: string[] //参与人员
  createTime: Date // 创建时间
  updateTime: Date // 创建时间
  backPath: string //返回地址
}

// 活动 API
export const ActivityApi = {
  // 查询活动分页
  getActivityPage: async (params: any) => {
    return await request.get({ url: `/school/activity/page`, params })
  },

  // 查询活动详情
  getActivity: async (id: number) => {
    return await request.get({ url: `/school/activity/get?id=` + id })
  },

  // 新增活动
  createActivity: async (data: ActivityVO) => {
    return await request.post({ url: `/school/activity/create`, data })
  },

  // 修改活动
  updateActivity: async (data: ActivityVO) => {
    return await request.put({ url: `/school/activity/update`, data })
  },

  // 删除活动
  deleteActivity: async (id: number) => {
    return await request.delete({ url: `/school/activity/delete?id=` + id })
  },

  // 导出活动 Excel
  exportActivity: async (params) => {
    return await request.download({ url: `/school/activity/export-excel`, params })
  },

  // ==================== 子表（活动参与记录） ====================

  // 获得活动参与记录概况
  getActivityRecordOverview: async (params) => {
    return await request.get({ url: `/school/activity/activity-record/overview`, params })
  },

  // 获得活动参与记录分页
  getActivityRecordPage: async (params) => {
    return await request.get({ url: `/school/activity/activity-record/page`, params })
  },
  // 新增活动参与记录
  createActivityRecord: async (data) => {
    return await request.post({ url: `/school/activity/activity-record/create`, data })
  },

  // 修改活动参与记录
  updateActivityRecord: async (data) => {
    return await request.put({ url: `/school/activity/activity-record/update`, data })
  },

  // 删除活动参与记录
  deleteActivityRecord: async (id: number) => {
    return await request.delete({ url: `/school/activity/activity-record/delete?id=` + id })
  },

  // 获得活动参与记录
  getActivityRecord: async (id: number) => {
    return await request.get({ url: `/school/activity/activity-record/get?id=` + id })
  }
}
